/* GUI CONVERTED from rcsodf.p (converter v1.76) Wed May 15 15:00:56 2002 */
/* rcsodf.p - BULK ASSIGN DOCUMENT FORMATS TO EXISTING SHIPPERS              */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                       */
/* All rights reserved worldwide.  This is an unpublished work.              */
/* $Revision: 1.5.1.3 $                                                         */
/*V8:ConvertMode=Maintenance                                                 */
/* REVISION: 8.6      LAST MODIFIED: 11/18/96   BY: *K003* Steve Goeke       */
/* REVISION: 8.6      LAST MODIFIED: 12/06/96   BY: *K030* Vinay Nayak-Sujir */
/* REVISION: 8.6      LAST MODIFIED: 03/15/97   BY: *K04X* Steve Goeke       */

/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan        */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan        */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00 BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00 BY: *N0KP* myb                 */
/* $Revision: 1.5.1.3 $    BY: John Pison            DATE: 05/13/02  ECO: *N1HN*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/
/* DISPLAY TITLE */
{mfdtitle.i "2+ "}

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE rcsodf_p_1 "Process Pre-Shippers/Shippers"
/* MaxLen: Comment: */

&SCOPED-DEFINE rcsodf_p_2 "Assign Document Format"
/* MaxLen: Comment: */

&SCOPED-DEFINE rcsodf_p_3 "Number"
/* MaxLen: Comment: */

&SCOPED-DEFINE rcsodf_p_4 "Address List Type"
/* MaxLen: Comment: */

&SCOPED-DEFINE rcsodf_p_5 "Pre-Shippers/Shippers"
/* MaxLen: Comment: */

&SCOPED-DEFINE rcsodf_p_6 "Include Printed Pre-Shippers/Shippers"
/* MaxLen: Comment: */

&SCOPED-DEFINE rcsodf_p_7 "Shipper Sequence ID"
/* MaxLen: Comment: */

&SCOPED-DEFINE rcsodf_p_8 "Ship-From"
/* MaxLen: Comment: */

&SCOPED-DEFINE rcsodf_p_9 "Ship-To/Dock"
/* MaxLen: Comment: */

&SCOPED-DEFINE rcsodf_p_10 "Skip If Format Already Assigned"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

/* LOCAL VARIABLES */

define variable shipfrom  like abs_shipfrom  label {&rcsodf_p_8} no-undo.
define variable shipfrom1 like abs_shipfrom                    no-undo.
define variable shipto    like abs_shipto label {&rcsodf_p_9} no-undo.
define variable shipto1   like abs_shipto                      no-undo.
define variable ship      like abs_id           label {&rcsodf_p_3} no-undo.
define variable ship1     like abs_id                          no-undo.
define variable range     as   character                       no-undo.
define variable range1    as   character                       no-undo.
define variable invmov    like abs_inv_mov                     no-undo.
define variable invmov1   like abs_inv_mov                     no-undo.
define variable fmt       like abs_format                      no-undo.
define variable fmt1      like abs_format                      no-undo.
define variable lang      like so_lang                         no-undo.
define variable lang1     like so_lang                         no-undo.
define variable listtype  like ls_type
   label {&rcsodf_p_4} no-undo.
define variable listtype1 like ls_type                         no-undo.
define variable carr      like absc_carrier                    no-undo.
define variable carr1     like absc_carrier                    no-undo.
define variable pick_ship as   logical format {&rcsodf_p_5}
   label {&rcsodf_p_1} no-undo.
define variable printed_prev like mfc_logical
   label {&rcsodf_p_6} no-undo.
define variable seq_id    like abs_nr_id
   label {&rcsodf_p_7} no-undo.
define variable skip_assigned like mfc_logical initial true
   label {&rcsodf_p_10} no-undo.
define variable new_fmt   like abs_format
   label {&rcsodf_p_2} no-undo.

define variable v_err     as   logical                         no-undo.
define variable v_errnum  as   integer                         no-undo.
define variable v_internal as  logical                         no-undo.
define variable v_type    as   character                       no-undo.
define variable v_label   like lngd_translation                no-undo.
define variable v_seq_id  like shc_ship_nr_id                  no-undo.
define variable v_shipgrp like sg_grp                          no-undo.

{sonrmdat.i}

/* BUFFERS */

define buffer b_abs_mstr for abs_mstr.

/* FRAMES */


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   /* Changed each colon 20 to 25 and each colon 49 to 52 */
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
shipfrom      colon 25
   shipfrom1     colon 52 label {t001.i}
   shipto        colon 25
   shipto1       colon 52 label {t001.i}
   ship          colon 25
   ship1         colon 52 label {t001.i}
   invmov        colon 25
   invmov1       colon 52 label {t001.i}
   fmt           colon 25
   fmt1          colon 52 label {t001.i}
   lang          colon 25
   lang1         colon 52 label {t001.i}
   listtype      colon 25
   listtype1     colon 52 label {t001.i}
   carr          colon 25
   carr1         colon 52 label {t001.i} skip(1)
   pick_ship     colon 43
   printed_prev  colon 43
   seq_id        colon 43
   skip_assigned colon 43 skip(1)
   new_fmt       colon 43
 SKIP(.4)  /*GUI*/
with frame a side-labels width 80 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

view frame a.

/* MAIN PROCEDURE BODY */

{gprun.i ""socrshc.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

find first shc_ctrl no-lock no-error.
v_seq_id = if available shc_ctrl then shc_ship_nr_id else "".

main-blk:
repeat:
/*GUI*/ if global-beam-me-up then undo, leave.


   /* RESET THE HIGH VALUES */
   if shipfrom1 = hi_char then shipfrom1 = "".
   if shipto1   = hi_char then shipto1   = "".
   if ship1     = hi_char then ship1     = "".
   if invmov1   = hi_char then invmov1   = "".
   if fmt1      = hi_char then fmt1      = "".
   if lang1     = hi_char then lang1     = "".
   if listtype1 = hi_char then listtype1 = "".
   if carr1     = hi_char then carr1     = "".

   update
      shipfrom  shipfrom1
      shipto    shipto1
      ship      ship1
      invmov    invmov1
      fmt       fmt1
      lang      lang1
      listtype  listtype1
      carr      carr1
      pick_ship
      printed_prev
      seq_id
      skip_assigned
      new_fmt
   with frame a.

   /* Validate sequence ID */

   if seq_id <> "" then do:

      run chk_valid(
         seq_id, shipper_dataset,
         output v_err, output v_errnum).

      if v_err then do:
         {mfmsg03.i v_errnum 3 seq_id """" """"}
         next-prompt seq_id with frame a.
         undo main-blk, retry main-blk.
      end.

      run chk_internal(
         seq_id, output v_internal,
         output v_err, output v_errnum).

      if v_err then do:
         {pxmsg.i &MSGNUM=v_errnum &ERRORLEVEL=3}
         next-prompt seq_id with frame a.
         undo main-blk, retry main-blk.
      end.

      if not v_internal then do:
         {pxmsg.i &MSGNUM=5843 &ERRORLEVEL=3} /* INVALID SEQUENCE */
         next-prompt seq_id with frame a.
         undo main-blk, retry main-blk.
      end.

   end. /* if seq_id <> ""  */

   /* Validate new document format */

   if new_fmt <> "" and
      not can-find(
      df_mstr where df_type = "1" and df_format = new_fmt)
   then do:

      /* Convert type code to mnemonic code for error message */
      {gplngn2a.i
         &file     = ""df_mstr""
         &field    = ""df_type""
         &code     = ""1""
         &mnemonic = v_type
         &label    = v_label}

      {mfmsg03.i 5900 3 v_type """" """"}.
      next-prompt new_fmt with frame a.
      undo main-blk, retry main-blk.

   end. /* if new_fmt <> ""  */

   /* SET THE HIGH VALUES */
   if shipfrom1 = "" then shipfrom1 = hi_char.
   if shipto1   = "" then shipto1   = hi_char.
   if ship1     = "" then ship1     = hi_char.
   if invmov1   = "" then invmov1   = hi_char.
   if fmt1      = "" then fmt1      = hi_char.
   if lang1     = "" then lang1     = hi_char.
   if listtype1 = "" then listtype1 = hi_char.
   if carr1     = "" then carr1     = hi_char.

   if pick_ship then
   assign
      range  = "p" + ship
      range1 = "p" + ship1.
   else
   assign
      range  = "s" + ship
      range1 = "s" + ship1.

   if not {gpiswrap.i} then do:
      {pxmsg.i &MSGNUM=832 &ERRORLEVEL=1}  /* PROCESSING... PLEASE WAIT */
   end.

   ship-blk:
   for each abs_mstr no-lock where
         abs_shipfrom >= shipfrom and abs_shipfrom <= shipfrom1 and
         abs_id       >= range    and abs_id       <= range1    and
         abs_shipto   >= shipto   and abs_shipto   <= shipto1   and
         abs_inv_mov  >= invmov   and abs_inv_mov  <= invmov1   and
         abs_format   >= fmt      and abs_format   <= fmt1      and
         abs_lang     >= lang     and abs_lang     <= lang1     and
         (abs_type    = "p"      or  abs_type     = "s")      and
         (not skip_assigned       or  abs_format   = "")
         on endkey undo, leave:
/*GUI*/ if global-beam-me-up then undo, leave.


      /* Check list type */

      find ls_mstr no-lock where ls_addr = abs_shipto no-error.
      if available ls_mstr and
         (ls_type < listtype or ls_type > listtype1)
         then next ship-blk.

      /* Check carrier */

      find first absc_det no-lock where absc_abs_id = abs_id no-error.
      if
         (if available absc_det
         then absc_carrier < carr or absc_carrier > carr1
         else carr > "")
         then next ship-blk.

      /* Check print status */

      if not printed_prev and substring(abs_status,1,1) = "y"
         then next ship-blk.

      /* Check shipper sequence */

      if seq_id <> "" and pick_ship then do:

         {gprun.i
            ""gpgetgrp.p""
            "(abs_shipfrom, abs_shipto, output v_shipgrp)"}
/*GUI*/ if global-beam-me-up then undo, leave.


         find first sgid_det no-lock where
            sgid_grp     = v_shipgrp and
            sgid_inv_mov = abs_inv_mov no-error.

         if seq_id ne
            (if available sgid_det
            then sgid_ship_nr_id
            else v_seq_id)
            then next ship-blk.

      end.  /* if seq_id */

      else if seq_id <> "" and abs_nr_id <> seq_id then next ship-blk.

      /* Set the new document format */

      do transaction:

         find b_abs_mstr exclusive-lock where
            recid(b_abs_mstr) = recid(abs_mstr).
         if available b_abs_mstr then b_abs_mstr.abs_format = new_fmt.

      end.  /* do transaction */
   end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* ship-blk */

   {pxmsg.i &MSGNUM=1107 &ERRORLEVEL=1}  /* PROCESS COMPLETE */

end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* main-blk */

/* Internal procedures for accessing NR attributes */
{gpnrseq.i}
